import {
    cateList,cateInfo,
} from "../../request/api"

const state = {
    cateList: [],
    cateInfo:{}
}
//导出
const getters = {
    cateList(state) {
        return state.cateList
    },
    cateInfo(state) {
        return state.cateInfo
    },
}
//修改
const mutations = {
    cCateList(state, data) {
        state.cateList = data;
    },
    cCateInfot(state, data) {
        state.cateInfo = data;
    },
}
// 异步逻辑
const actions = {
    reqCateList(context) {
        cateList({istree:true}).then(res => { 
            context.commit("cCateList", res.data.list)
        })
    },
    reqCateInfo(context,data) {
        cateInfo({id:data}).then(res => { 
            res.data.list.id = data
            context.commit("cCateInfot", res.data.list)
        })
    },
}

export default {
    state,
    getters,
    mutations,
    actions,
    namespaced: true
}